﻿@model PH.Model.Systems.NoticeModel

<div class="GeneralEdit" id="fmNotice">
    <ul>
         <li>
            <label for="txtTitle">标题：</label>
            <input type="text" class="k-textbox" id="txtTitle" name="title" value="@Model.Title" required validationMessage="请输入标题" />
            <span class="k-invalid-msg" data-for="title"></span>
        </li>
        <li>
            <label for="txtExpired">截止时间：</label>
            <input type="date" id="txtExpired" name="expired" class="date" required validationMessage="请选择截止时间" />
            <span class="k-invalid-msg" data-for="expired"></span>
        </li>
        <li>
            <label for="txtDescription"></label>
            <textarea id="txtDescription" name="description" rows="5" cols="30">@Model.Description</textarea>
        </li>
        <li class="editButtons">
            <button id="btnSave" class="k-button"><span class="k-icon k-i-tick"></span><span>确认提交</span></button>
            &nbsp;&nbsp;
            <button class="k-button" onclick="CancelGeneralEdit();"><span class="k-icon k-i-cancel"></span><span>&nbsp;返&nbsp;回</span></button>
        </li>
    </ul>
</div>

<script class="init">
    $(".date").kendoDatePicker({
        format: "yyyy-MM-dd"
    });
    $("#txtDescription").kendoEditor({
        tools: [
                "bold",
                "italic",
                "underline",
                "strikethrough",
                "justifyLeft",
                "justifyCenter",
                "justifyRight",
                "justifyFull",
                "insertUnorderedList",
                "insertOrderedList",
                "indent",
                "outdent",
                "createLink",
                "unlink",
                "insertImage",
                "insertFile",
                "subscript",
                "superscript",
                "createTable",
                "addRowAbove",
                "addRowBelow",
                "addColumnLeft",
                "addColumnRight",
                "deleteRow",
                "deleteColumn",
                "viewHtml",
                "formatting",
                "cleanFormatting",
                "fontName",
                "fontSize",
                "foreColor",
                "backColor"
        ]
    });
    if ("@(Model.ID>0)" == "True") {
        $("#txtExpired").data("kendoDatePicker").value(kendo.parseDate('@string.Format("{0:yyyy-MM-dd}",Model.Expired)'));

    }
</script>

<script class="save_class">
    $(function () {
        var validator = $("#fmNotice").kendoValidator().data("kendoValidator");
        $("#btnSave").click(function (e) {
            if (validator.validate()) {
                var values = {
                    id: "@Model.ID",
                    title: $("#txtTitle").val(),
                    expired: kendo.toString($("#txtExpired").data("kendoDatePicker").value(), "yyyy-MM-dd"),
                    description: $("#txtDescription").data("kendoEditor").value(),
                };

                Whale.Remote.Operation({
                    url: "/Systems/Notice/Save",
                    parameters: values,
                    success: function (result) {
                        wndGeneralEdit.close();
                        if ($("#grid_notice").length > 0)
                            $("#grid_notice").data("kendoGrid").dataSource.read();
                    },
                    error: function (msg) {
                        wndGeneralInformation.content(msg).open();
                    }
                });
            }
            return false;
        });
    });
</script>
